<template>
  <ul class="tab-bar">
    <li
      class="tab-bar-item"
      v-for="nav in navs"
      :key="nav.path"
      is="router-link"
      :to="nav.path"
      tag="li"
    >
      <div class="icon"><i class="iconfont" v-html="nav.meta.icon"></i></div>
      <div class="title">{{nav.meta.title}}</div>
    </li>
  </ul>
</template>

<script>
import routes from '@/router/routes'

export default {
  name: 'TabBar',
  computed: {
    // 计算出在 TabBar 上的每一项
    navs() {
      return routes.filter(route => route.meta?.inTabBar)
    },
  },
}
</script>

<style lang="less" scoped>
  @font-face {
    font-family: 'iconfont';  /* Project id 2625780 */
    src: url('//at.alicdn.com/t/font_2625780_rwvg4wh1mvh.woff2?t=1624344451207') format('woff2'),
        url('//at.alicdn.com/t/font_2625780_rwvg4wh1mvh.woff?t=1624344451207') format('woff'),
        url('//at.alicdn.com/t/font_2625780_rwvg4wh1mvh.ttf?t=1624344451207') format('truetype');
  }
  .iconfont{
    font-family:"iconfont" !important;
    font-size:16px;font-style:normal;
    -webkit-font-smoothing: antialiased;
    -webkit-text-stroke-width: 0.2px;
    -moz-osx-font-smoothing: grayscale;
  }

  .tab-bar {
    display: flex;
    height: 108px;
    color: #333;
    &-item {
      flex: 1;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: space-around;

      .icon {
        font-size: 24px;
      }
    }
  }

  .router-link-exact-active, .router-link-active {
    color: #d81e06;
  }
</style>
